<?php

/**
 * desc 后台访问基类
 * Class BaseAdmin
 */
class BaseAdmin
{
	protected $uid = false;
	protected $userinfo = [];
	protected $loginUrl = '';

	public function __construct()
	{
		if (!$this->isAdminLogin()) {
            $fromUrl = Request::Url();
            $_SESSION['from_url'] = urlencode($fromUrl);
            $this->loginUrl = Fun::buildUrl('user', 'login', 'index');
		    Response::redirect('请登录', $this->loginUrl);
        }
	}
    
    public function isAdminLogin()
    {
        $rs = User::getUserCookie();
        // if (empty($rs) || $rs['role'] != 1) {
        if (empty($rs) || $rs['uid'] != 1) {
            return FALSE;
        } else {
            return TRUE;
        }
    }
}